using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Tool
{
    public partial class DeleteDialog : Form
    {
        private System.Windows.Forms.Form m_Parent;

        public DeleteDialog(System.Windows.Forms.Form parent)
        {
            InitializeComponent();
            m_Parent = parent;
        }

        private void DeleteDialog_Load(object sender, EventArgs e)
        {
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
        }

        private void DeleteAccept_Click(object sender, EventArgs e)
        {
            TreeNode currNode = ((Editor)m_Parent).CurrentSelectedNode();
   
                // This is an event
            if( ((Editor)m_Parent).EventTree.SelectedNode.Parent == null )
            {
                ((Editor)m_Parent).DeleteEventNode(currNode);
                ((Editor)m_Parent).GetEventTree().RemoveEvent(currNode.Text);
            }
            else
            {
                int selectedIndex = ((Editor)m_Parent).EventTree.SelectedNode.Index;

                ((Editor)m_Parent).GetEventTree().RemoveSound(((Editor)m_Parent).EventTree.SelectedNode.Parent.Text, selectedIndex);

                ((Editor)m_Parent).EventTree.SelectedNode.Remove();
                //((Editor)m_Parent).EventTree.SelectedNode = ((Editor)m_Parent).EventTree.SelectedNode.Parent;
            }

            this.Close();
        }

        private void DeleteCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}